﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Whir.Common.WebHelper;

public partial class Whir_System_Module_download_list : System.Web.UI.Page
{
   
    protected void Page_Load(object sender, EventArgs e)
    {
      
        if (!IsPostBack)
        {
            BindData();
        }
    }

    private void BindData()
    {
        string where = " TypeID in (18,22,34)";
        string countSql = "SELECT COUNT(*) FROM Whir_U_News WHERE " + where;
        
        DataTable dt = Whir.SQLServerDAL.DbHelperSQL.GetList("Whir_U_News", "Whir_U_News_PID", "*", AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex - 1, where, "", "CreateDate desc").Tables[0];

        if (dt.Rows.Count>0 && dt!=null)
        {
            AspNetPager1.RecordCount = int.Parse(Whir.SQLServerDAL.DbHelperSQL.GetSingle(countSql).ToString());
            GridView1.DataSource = dt;
            GridView1.DataBind();
        }
        else
        {
            GridView1.Controls.Clear();
            divMessage.Visible = true;
        }
    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        BindData();
    }

    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {

    }

    protected void btnDelete_Click(object sender, EventArgs e)
    {
        
        //获取被选中的编号
        int[] itemIds = this.GridView1.CheckedIndexs;
        if (itemIds.Length > 0)
        {
            foreach (int item in itemIds)
            {
                string sql = "delete from Whir_U_News where Whir_U_News_PID="+item;
                Whir.SQLServerDAL.DbHelperSQL.ExecuteSql(sql);
            }
            JsHelper.Alert(Page, "该记录已删除成功！");
            BindData();
        }
        else
        {
            JsHelper.Alert(Page, "请选择要删除的记录！");
        }
    }
}
